

insert into asm_anagrafe_sito_ue






select distinct 0,trim(sog_codfis),'' sog_pariva,
max(sog_ragsoc),max(sog_tel),max(sog_numcell),max(sog_fax),max(sog_email),'' PASSWORD,'F',max(sog_id),'',''
from sic4u_ambUE.soggetto
where  SOG_FLPFG = '0'  and az_id = '01' and trim(sog_CODFIS) is not null

GROUP BY trim(sog_CODFIS);


insert into asm_anagrafe_sito_ue




select distinct  0,'' sog_codfis,trim(sog_pariva),
max(sog_ragsoc),MIN(TRIM(sog_TEL)),Max(TRIM(sog_NUMCELL)),Max(TRIM(sog_FAX)),Max(TRIM(sog_EMAIL)),'' PASSWORD,'G',max(sog_id),'',''

 from sic4u_ambUE.v_soggetto 
where  SOG_FLPFG <> '0' and az_id = '01' and trim(sog_pariva) is not null and  trim(sog_CODFIS) is null

GROUP BY trim(sog_PARIVA)








